package com.jilefojing.beans.pojos.enhanced;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Date;

import com.jilefojing.beans.enums.ItemTypeEnumForSource;
import com.jilefojing.beans.enums.forexpose.StatusEnumForExpose;
import com.jilefojing.beans.enums.forexpose.TypeEnumForExpose;
import com.jilefojing.beans.pojos.Expose;
import com.jilefojing.beans.pojos.enhanced.base.BaseEnhanced;

/**
 * 
 * @author 作者 jgshun
 * @date 创建时间 2016年07月24日 22时00分27秒
 */
public class EnhancedExpose extends BaseEnhanced {
	public EnhancedExpose(Expose expose) {
		// TODO 自动生成 细微误差自己调整
		if (expose.getId() != null) {
			this.id = expose.getId();
		}
		if (expose.getItemType() != null) {
			this.itemType = ItemTypeEnumForSource.getItemTypeEnumByCode(expose.getItemType());
		}
		if (expose.getItemId() != null && this.itemType != null) {
			try {
				Class<? extends BaseEnhanced> _EnhancedClass = this.itemType.getEnhancedItemClass();
				BaseEnhanced _EnhancedItem = _EnhancedClass.newInstance();
				for (Method _Method : _EnhancedClass.getDeclaredMethods()) {
					if (_Method.getName().equals("setId")) {
						_Method.invoke(_EnhancedItem, expose.getItemId());
						break;
					}
				}
				this.enhancedItem = _EnhancedItem;
			} catch (SecurityException e) {
				e.printStackTrace();
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				e.printStackTrace();
			} catch (InstantiationException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}
		if (expose.getType() != null) {
			this.type = TypeEnumForExpose.getTypeEnumByCode(expose.getType());
		}
		this.content = expose.getContent();
		if (expose.getUserId() != null) {
			EnhancedUser enhancedUser = new EnhancedUser();
			enhancedUser.setId(expose.getUserId());
			this.enhancedUser = enhancedUser;
		}
		this.createTime = expose.getCreateTime();
		this.updateTime = expose.getUpdateTime();
		this.dealTime = expose.getDealTime();
		if (expose.getDealUserId() != null) {
			EnhancedUser _EnhancedDealUser = new EnhancedUser();
			_EnhancedDealUser.setId(expose.getDealUserId());
			this.enhancedDealUser = _EnhancedDealUser;
		}
		if (expose.getStatus() != null) {
			this.status = StatusEnumForExpose.getStatusEnumByCode(expose.getStatus());
		}
		this.dealResult = expose.getDealResult();
	}

	public EnhancedExpose() {
	}

	private long id;
	private ItemTypeEnumForSource itemType;
	private BaseEnhanced enhancedItem;
	private TypeEnumForExpose type;
	private String content;
	private EnhancedUser enhancedUser;
	private Date createTime;
	private Date updateTime;
	private Date dealTime;
	private EnhancedUser enhancedDealUser;
	private StatusEnumForExpose status;
	private String dealResult;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public ItemTypeEnumForSource getItemType() {
		return itemType;
	}

	public void setItemType(ItemTypeEnumForSource itemType) {
		this.itemType = itemType;
	}

	public BaseEnhanced getEnhancedItem() {
		return enhancedItem;
	}

	public void setEnhancedItem(BaseEnhanced enhancedItem) {
		this.enhancedItem = enhancedItem;
	}

	public TypeEnumForExpose getType() {
		return type;
	}

	public void setType(TypeEnumForExpose type) {
		this.type = type;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public EnhancedUser getEnhancedUser() {
		return enhancedUser;
	}

	public void setEnhancedUser(EnhancedUser enhancedUser) {
		this.enhancedUser = enhancedUser;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Date getDealTime() {
		return dealTime;
	}

	public void setDealTime(Date dealTime) {
		this.dealTime = dealTime;
	}

	public EnhancedUser getEnhancedDealUser() {
		return enhancedDealUser;
	}

	public void setEnhancedDealUser(EnhancedUser enhancedDealUser) {
		this.enhancedDealUser = enhancedDealUser;
	}

	public StatusEnumForExpose getStatus() {
		return status;
	}

	public void setStatus(StatusEnumForExpose status) {
		this.status = status;
	}

	public String getDealResult() {
		return dealResult;
	}

	public void setDealResult(String dealResult) {
		this.dealResult = dealResult;
	}

}